package com.text;

import com.entity.User;
import com.service.user.UserService;
import org.apache.log4j.Logger;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.ArrayList;
import java.util.List;

public class UserTest {
    private static final Logger logger = Logger.getLogger(UserTest.class);
    @Test
    private void testGetUserList(){
        ApplicationContext ctx = new ClassPathXmlApplicationContext(
                "applicationContext-mybatis.xml");//,"applicationContext-dao.xml","applicationContext-service.xml)"
                String configss="applicationContext*.xml";
                String[] configs = {"applicationContext-mybatis.xml","applicationContext-dao.xml","applicationContext-service.xml"};
        UserService userService = (UserService)ctx.getBean("userService");
        List<User> userList = new ArrayList<User>();

        User user = new User();
        user.setUserRole(3);
        user.setUserName("赵");

        userList = userService.findUsersWithConditions(user);

        for (User userResult : userList) {
            logger.info("testGetUserList usercde:"+ userResult.getUserCode() + "and userName:"
                                                        +userResult.getUserName()+ "and userRole:"
                                                        +userResult.getRole()+"and userRoleName:"
                                                        +userResult.getUserRoleName()+"and address:"+userResult.getAddress());
        }
    }
}
